package services

import (
	"fmt"
	"time"

	common "jihe.common"
	"jihe.common/protos/base_server/proto"
	"jihe.common/tool"
)

type Option struct {
	Label string `json:"label"`
	Value int64  `json:"value"`
	Tag   string `json:"tag"`
}

func GetOptions(key string) (ret *proto.BaseFashionTypes) {
	ret = new(proto.BaseFashionTypes)
	reqUrl := fmt.Sprintf("%s/options.json?%d", common.Configer.Oss.Domain, time.Now().Unix())
	opt := make(map[string][]Option)
	tool.Request.Timeout(time.Second * 5).Get(reqUrl).EndStruct(&opt)
	for _, v := range opt[key] {
		item := &proto.BaseFashionType{Label: v.Label, Value: v.Value, Tag: v.Tag}
		ret.BaseFashionTypeList = append(ret.BaseFashionTypeList, item)
	}
	return
}
